package com.hotel.meals.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotel.common.vo.R;
import com.hotel.meals.mapper.FoodMapper;
import com.hotel.meals.service.FoodService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotel.user.entity.Food;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author KK
 * @since 2024-06-19
 */
@Service
public class FoodServiceImpl extends ServiceImpl<FoodMapper, Food> implements FoodService {

    @Autowired
    private FoodMapper foodMapper;

    @Override
    public List<Food> getAllFoods(String category) {
        List<Food> foods = new ArrayList<>();
        QueryWrapper<Food> foodQueryWrapper = new QueryWrapper<>();
        if (category.equals("1")) {
            foodQueryWrapper.eq("category", "1");
            foods = foodMapper.selectList(foodQueryWrapper);
        } else if (category.equals("2")){
            foodQueryWrapper.eq("category", "2");
            foods = foodMapper.selectList(foodQueryWrapper);
        }
        return foods;
    }
}
